
var http = require('http');
var fs = require('fs');
var path = require('path');
var url = require('url');

http.createServer(function(req,res){
      console.log("server call");

      var pathname = url.parse(req.url).path;
      if(pathname=='/')
            pathname='/index.html';
      pathname = pathname.substring(1,pathname.length);

      var mimeTypes = {
            '.js':'text/javascript',
            '.css':'text/css',
            '.html':'text/html'
      };

      fs.readFile(pathname,'utf8',function(err,data){
            res.writeHead(200,{'Content-Type':mimeTypes[path.extname(pathname)]});
            res.end(data);
      });


}).listen(4000);

